package com.dnw.httpUtil;



import com.dnw.modle.NewsDetail;
import com.dnw.modle.Program;
import com.dnw.modle.Result;
import com.dnw.response.CommentResponse;
import com.dnw.response.FunnysResponse;
import com.dnw.response.FunnysResponseById;
import com.dnw.response.NewsResponse;
import com.dnw.response.ResultResponse;
import com.dnw.response.VideoPathResponse;

import java.util.List;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

import retrofit2.http.Url;
import rx.Observable;

/**
 * @author ChayChan
 * @description: 网络请求的service
 * @date 2017/6/18  19:28
 */

public interface ApiService {
    String GET_PROGRAM          = "app-recomm/list.do";
    String GET_PROGRAM_DOWNLOAD = "app-recomm/to-download.do";
    String GET_OPINION_RESULT   = "feedback/add.do";
    String GET_ARTICLE_LIST     = "api/news/feed/v62/?refer=1&count=20&loc_mode=4&device_id=34960436458&iid=13136511752";
    String GET_COMMENT_LIST     = "article/v2/tab_comments/";
    String GET_FUNNY_LIST       = "/joke/dzlist.do";
    String GET_FUNNY_LIST_BY_ID       = "/joke/dz-content.do";

    String DO_FUNNY_LIKE_OR       = "/joke/like.do";
    String GET_APP_VERSION       = "/app-version.do";
    String GET_IS_APPROVED      = "/app-version/is-approved.do";
//    String GET_UPDATE_FILE      ="/download/apk/shyfunny.apk";


    //http://is.snssdk.com
    //http://is.snssdk.com/api/news/feed/v54/?refer=1&count=20&min_behot_time=1498722625&last_refresh_sub_entrance_interval=1498724693&loc_mode=4&tt_from=pull（tab_tip） 新闻列表
    //http://is.snssdk.com/article/v2/tab_comments/?group_id=6436886053704958466&item_id=6436886053704958466&offset=30&count=20 评论
    //http://is.snssdk.com/2/article/information/v21/ 详情

    @GET(GET_PROGRAM)
    Observable<Result<List<Program>>> getProgram();

    @GET(GET_PROGRAM_DOWNLOAD)
    Observable<Result> getProgramDownload(@Query("appRecommendId") int appRecommendId);

    @GET(GET_OPINION_RESULT)
    Observable<Result> getOpinionResult(@Query("content") String content);

    @GET(GET_IS_APPROVED)
    Observable<Result> getIsApproved();

    @FormUrlEncoded
    @POST(GET_FUNNY_LIST)
    Observable<FunnysResponse> getFunnysList(@Field("mediaType") String type, @Field("pageOn") String pageOn,
                                             @Field("pageSize") String pageSize, @Field(value = "searchKey") String searchKey,
                                             @Field(value = "labelName") String labelName);

    @GET(GET_FUNNY_LIST_BY_ID)
    Observable<FunnysResponseById> getFunnysListById(@Query("dzId") String dzId);


    @FormUrlEncoded
    @POST(DO_FUNNY_LIKE_OR)
    Observable<Result> doFunnysLikeOr(@Field("jokeId") String jokeId, @Field("userId") String userId, @Field("userOperateEnum") String userOperateEnum);

    @POST(GET_APP_VERSION)
    Observable<Result> getAppVersion();


//    @Streaming
//    @GET(GET_UPDATE_FILE)
//    Observable<ApkData>getUpdateFile();

    /**
     * 获取新闻列表
     *
     * @param category 频道
     * @return
     */
    @GET(GET_ARTICLE_LIST)
    Observable<NewsResponse> getNewsList(@Query("category") String category, @Query("min_behot_time") long lastTime, @Query("last_refresh_sub_entrance_interval") long currentTime);

    //
    //    /**
    //     * 获取新闻详情
    //     */
    @GET
    Observable<ResultResponse<NewsDetail>> getNewsDetail(@Url String url);

    //
    //    /**
    //     * 获取评论列表数据
    //     *
    //     * @param groupId
    //     * @param itemId
    //     * @param offset
    //     * @param count
    //     * @return
    //     */
    @GET(GET_COMMENT_LIST)
    Observable<CommentResponse> getComment(@Query("group_id") String groupId, @Query("item_id") String itemId, @Query("offset") String offset, @Query("count") String count);

    //
    //    /**
    //     * 获取视频数据json
    //     *
    //     * @param url
    //     * @return
    //     */
    //    @GET
    //    Observable<ResultResponse<VideoModel>> getVideoData(@Url String url);
    //
    //    @Headers({
    //            "Content-Type:application/x-www-form-urlencoded; charset=UTF-8",
    //            "Cookie:PHPSESSIID=334267171504; _ga=GA1.2.646236375.1499951727; _gid=GA1.2.951962968.1507171739; Hm_lvt_e0a6a4397bcb500e807c5228d70253c8=1507174305;Hm_lpvt_e0a6a4397bcb500e807c5228d70253c8=1507174305; _gat=1",
    //            "Origin:http://toutiao.iiilab.com"
    //
    //    })
    @POST("http://service.iiilab.com/video/toutiao")
    Observable<VideoPathResponse> getVideoPath(@Query("link") String link, @Query("r") String r, @Query("s") String s);
}

